package com.java.concurrent;

import java.util.concurrent.CountDownLatch;

/**
 * h
 *
 * @author wwm
 * @create 2017-04-18 15:43
 **/
public class Decrementer implements Runnable {

    CountDownLatch latch = null;

    public Decrementer(CountDownLatch latch) {
        this.latch = latch;
    }

    public void run() {

        try {
            Thread.sleep(1000);
            this.latch.countDown();
 System.out.println(this.latch.getCount() );
            Thread.sleep(1000);
            this.latch.countDown();
            System.out.println(this.latch.getCount() );
            Thread.sleep(1000);
            this.latch.countDown();
            System.out.println(this.latch.getCount() );

            this.latch.countDown();
            System.out.println("ddd");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}